/************************************************************************
  * Copyright(c) 2023 Levetop Semiconductor Co.,Led. All rights reserved.
  * @file     rtc.h
  * @author   UartTFT Application Team
  * @version  V0.0.1
  * @date     2023-01-01
  * @brief    
 *************************************************************************/

#ifndef _RTC_H
#define _RTC_H

#include "data.h"
#include "bsp.h"

typedef struct
{
	volatile unsigned short int w_year;
	volatile unsigned char w_month;
	volatile unsigned char w_date;
	volatile unsigned char hour;
	volatile unsigned char min;
	volatile unsigned char sec;
	volatile unsigned char week;
} _calendar_obj;
extern _calendar_obj calendar;	// the Gregorian calendar

typedef struct _tm{
	// date and time components
	UINT16 day;
	UINT8  hour;
	UINT8  minute;
	UINT8  second;
}tm;
#define  RTC_BASE_YEAR  1970  // 锟斤拷准锟斤拷锟�
uint8_t LT_RtcInit(void);
void PMU_RTC_IRQHandler(void);

void RTC_Set_time(tm timer);
void RTC_Set_alarm(tm timer);

uint8_t Is_Leap_Year(uint16_t year);
uint16_t RTC_DateToDays(uint16_t syear, uint8_t smon, uint8_t sday);
uint8_t RTC_Set(uint16_t syear, uint8_t smon, uint8_t sday, uint8_t hour, uint8_t min, uint8_t sec);
uint16_t RTC_Get(void);
uint8_t RTC_Get_Week(uint16_t year, uint8_t month, uint8_t day);

#endif /* _RTC_H */
